<?php
	$params = array(
			'title'=>'',
			'submitter_name'=>'',
			'list_category_id'=>'',
			'status'=>'',
			);	
	//code to populate search data in search form starts here
	if(isset($this->params['named']))
	{
		$params = am($params,$this->params['named']);
	}
	//set category when viewing specific category listings.
	if(isset($this->params['named']['category']))
	{
		$params['list_category_id'] = $this->params['named']['category'];
	}
	
	//code to populate search data in search form ends here
	$statusOptions = array();
	$categories = cri('ListCategory')->getOptions();
	$model = $this->params['models']['0'];
	
	switch($model)
	{
		case 'Listing':
			$statusOptions = array(
				Listing::PUBLISH => __('Published'),
				Listing::UNPUBLISH => __('Unpublished'),
				'featured' => __('Featured')
			);
		break;		
		case 'Review':
			$statusOptions = array(
				Review::PUBLISHED => __('Published'),
				Review::UNPUBLISHED => __('Unpublished'),
				'featured'=>__('Featured'),
				'user_review'=>__('User reviews'),			
			);
			if(cr('GeneralConfig.disable_editor_reviews') == false)
			{
				$statusOptions['editor_review'] = __("Editor reviews");
			}
			$allowComment = cr('ReviewConfig.guest_write_review');
			if($allowComment)
			{
				$statusOptions['guest_review'] = __('Guest reviews');
			}	
		break;		
		case 'ReviewComment':
			$statusOptions = array(
				ReviewComment::PUBLISH => __('Published'),
				ReviewComment::UNPUBLISH => __('Unpublished'),		
			);	
			$allowComment = cr('ReviewConfig.allow_guest_comment');
			if($allowComment)
			{
				$statusOptions['guest_comments'] = __('Guest Comments');
			}
		break;
	}	
?>
	
<?php	
	echo $form->create($model,array('url'=>array('action'=>'admin_index','search'=>"1"),'class'=>'admin_search'));
	if($model != 'ReviewComment')
	{
		echo $form->input('title',array('value'=>$params['title']));
	}
	echo $form->input('submitter_name',array('label'=>__('User'),'value'=>$params['submitter_name']));
	echo $form->input('list_category_id',array('label'=>__('Category'),'type'=>'select','empty'=>__('All'),'options'=>$categories,'selected'=>$params['list_category_id']));
	echo $form->input('status',array('type'=>'select','empty'=>__('All'),'options'=>$statusOptions,'selected'=>$params['status']));
	echo $form->submit(__('Search'));?>
	<div class="clear"></div></form><?php
?>
